<h1>Source Types</h1>

<table>
  <tr>
    <th>Name</th>
    <th>Scientific Name</th>
    <th>Edibility</th>
    <th>USDA Symbol</th>
    <th></th>
    <th></th>
  </tr>

<% @types.each do |type| %>
  <tr>
    <td>
    <% unless type.wikipedia_url.nil? %>
     <a href="<%= raw type.wikipedia_url %>" target="_blank"><%= type.name %></a>
    <% else %>
     <%= type.name %>
    <% end %>
    <%= "(#{type.synonyms})" unless type.synonyms.nil? or type.synonyms == ""%>
    </td>
    <td><em><%= type.scientific_name %> <%= "(#{type.scientific_synonyms})" unless type.scientific_synonyms.nil? or type.scientific_synonyms == "" %></em></td>
    <td><%= Type::Edabilities[type.edability] unless type.edability.nil? %>
    <td><%= raw !type.usda_symbol.nil? ? "<a href=\"http://plants.usda.gov/java/profile?symbol=#{type.usda_symbol}\">#{type.usda_symbol}</a>" : "?"%></em></td>

    <td><%= link_to 'Edit', edit_type_path(type) %></td>
    <td><%= link_to 'Destroy', type, method: :delete, data: { confirm: 'Are you sure?' } %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Type', new_type_path %>
